package com.saybiu.controller;

import com.saybiu.domain.Support;
import com.saybiu.response.ApiResult;
import com.saybiu.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wangwei
 * @Date 2021/4/21 15:12
 * @Version 1.0
 */
@RestController
public class SupportController {
    @Resource
    private UserService userService;
    //查询用户关注(userid,null)正向查
    //查询用户粉丝(null,userid)反向查

    /**
     * 查询关注人集合
     * @param userId
     * @return
     */
    @GetMapping(value = "/supports")
    public List<Support> selectAttention(Integer userId){
        //token获取id
        //查关注人
        List<Support> supports = userService.queryUserSupportAndBeSupported(userId, null);
        return supports;

    }

    /**
     * 查询粉丝集合
     * @param beSupportedUserId 用户自己id
     * @param  userId 无用
     * @return
     */
    @GetMapping(value = "/supports/{beSupportedUserId}")
    public List<Support> selectFans(@PathVariable("beSupportedUserId")Integer beSupportedUserId,Integer userId){
        //查粉丝
        List<Support> supports = userService.queryUserSupportAndBeSupported(null, beSupportedUserId);
        return supports;
    }
}
